// pages/cashService/third/list/list.wxml.js
const { request } = require('../../../../utils/request');
import Dialog from '../../../../miniprogram_npm/@vant/weapp/dialog/dialog'
Page({
  /**
   * 页面的初始数据
   */
  data: {
    loading:false,
    finished:false,
    listHttpFlag:true,//true可请求
    isEnd:false,
    comArray: [], //企业
    stationArray:[], //清点列表站点
    stationArray2:[], //历史列表站点
    lineArr:[],
    bagList: [],
    sumMoney:0, //交款总额
    totalMoney:0,//界面上显示的交款金额合计更改为由后端计算
    listLength:0,//界面上显示的箱包列表总数也更改为由后端获取
    sumIn:0, //入账金额总额
    loginType:'', // 0匿名登录 1站点操作 2站点管理 3企业管理 4三方操作 5三方管理
    showIdInput:false,
    scanSelectTip:'请选择扫码方式',
    bagCode:'',
    
    checkResultOptions: {
      TODO: '待办',
      BACK: '待退回',
      // ORIGIN: '按交款金额入账',
      // CHECK: '按清点金额入账',
      INPUT: '待汇总'
    },
    checkStatusOptions: {
      0:'待金库处理',
      1: '清点中',
      2: '待确认',
      3: '待入帐',
      4: '已入账',
      5: '待退回',
      6: '退回',
      7: '待汇总',
      8: '待清点',
      9: '清点中'
    },
    activeNames: 0,//展开组件
    activeNames2:0,//历史列表展开组件
    minDate: new Date('2021/12/01').getTime(),
    maxDate: new Date().getTime(),
    showStationSelector:false,
    queryOrder: {
      self:'',
      pageNo: 1,
      pageSize:50,
      checkStatusList: '7,9,5',
      payDate: '', //缴款日期
      payDateStart: '',
      payDateEnd: '',
      cIndex:0, //选择的企业下标
      companyId:0, //企业id
      sIndex:0, //选择的站点下标
      stationId:'', //站点id
      lineIndex:0,
      lineId:''
    },
    queryDone: {
      self:'',
      pageNo: 1,
      pageSize:50,
      checkStatusList: '0,1,2,3,4,6',
      payDate: '',
      payDateStart: '',
      payDateEnd: '',
      cIndex:0, //选择的企业下标
      companyId:0, //企业id
      sIndex:0, //选择的站点下标
      stationId:'', //站点id
      lineIndex:0,
      lineId:''
    },
    selectMode: '',
    selectMode1: '',
    tabActive:0, //tab下标
    minMoney:0,
    maxMoney:0,
    bagItem:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      loginType: wx.getStorageSync('userInfo').loginType
    })
    console.log('登录类型',this.data.loginType)
    if(this.data.loginType == 4){ //三方操作
      this.setData({
        ['queryOrder.self']:true,
        ['queryDone.self']:true
      })
    }else if(this.data.loginType == 5){ //三方管理
      this.setData({
        ['queryOrder.self']:false,
        ['queryDone.self']:false
      })
    }
    this.getCompany();
    wx.setNavigationBarTitle({
      title: '清点工作台',
    })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },
  /**
   * 获取公司列表
   * self:true个人 false团队
   * status:
   */
  getCompany(){
    request('/smsk/outsource/company', 'GET',{self:false }).then(res => {
      console.log(res.data)
      if (res.data.data.length != 0) {
        this.getStations(res.data.data[0].id)
        this.setData({
          comArray:res.data.data,
          ["queryOrder.companyId"]:res.data.data[0].id,
          ["queryDone.companyId"]:res.data.data[0].id,
        })
        this.fetchBagList();
      } else {
        console.log(res)
      }
    })
  },
  /**
   * 获取站点列表
   */
  getStations(cId,mode){
    this.getStationIine(cId);
    request('/smsk/outsource/stations', 'GET',{companyId:cId}).then(res => {
      console.log(res.data)
      if (res.data.code == 0) {
        res.data.data.unshift({id:'',stationName:'全部'})
        if( !mode ){
          this.setData({
            stationArray:res.data.data,
            stationArray2:res.data.data
          })
        }else if( mode === 'order'){
          this.setData({
            stationArray:res.data.data,
            ['queryOrder.sIndex']:0,
            ['queryOrder.stationId']:res.data.data[0].id,
          })
        }else if( mode === 'done'){
          this.setData({
            stationArray2:res.data.data,
            ['queryDone.sIndex']:0,
            ['queryDone.stationId']:res.data.data[0].id
          })
        }
      } else {
        console.log(res)
      }
    })
  },
  /**
   * 获取路线列表
   * @param {*} e 
   */
  getStationIine(cId,mode){
    request('/smsk/outsource/lines', 'GET',{companyId:cId}).then(res => {
      console.log(res.data)
      if (res.data.code == 0) {
        res.data.data.unshift({lineId:'',lineName:'全部'})
          this.setData({
            lineArr:res.data.data
          })
        }
    })
  },
  pagePlus(e){
    if(this.data.listHttpFlag === false){
      return;
    }
    if(e.currentTarget.dataset.mode==='order'){
      this.setData({
        ['queryOrder.pageNo'] : this.data.queryOrder.pageNo + 1
      })
      this.fetchBagList();
      console.log(this.data.queryOrder.pageNo,'列表页数')
    }else if(e.currentTarget.dataset.mode === 'done'){
      this.setData({
        ['queryDone.pageNo'] : this.data.queryDone.pageNo + 1
      })
      this.fetchDoneList();
      console.log(this.data.queryDone.pageNo,'历史页数')
    }
  },
  send2Bank(){
    if (this.data.bagList.length == 0) {
      return
    }
    let tempIds = []
    var flag = true;
    for(var i = 0;i<this.data.bagList.length;i++){
      if(this.data.bagList[i].bagsStatus != 7){
        wx.showToast({
          title: '列表中含有退回/待办箱包，请先处理箱包！',
          icon:'none'
        })
        flag = false;
      }
    }
    if(!flag){
      return
    }
    request('/smsk/outsource/confirming/collect', 'POST', { companyId: this.data.bagList[0].companyId, payDate: this.data.bagList[0].payDate }).then(res => {
      console.log(res.data)
      if (res.data.code === 0) {
        wx.showToast({
          title: '提交成功',
          icon: 'success'
        })
        this.setData({ 
          ['queryOrder.pageNo']: 1, 
          listHttpFlag: true, 
          isEnd: false, 
          bagList: [] 
        })
        this.fetchBagList();
      }else{
        wx.showToast({
          title: res.data.message,
          icon: 'none'
        })
      }
    })
  },
  /**
   * 退回操作
   */
  handleBack(e){
    console.log(e.currentTarget.id);
    request('/smsk/outsource/confirming/return', 'POST',{id:e.currentTarget.id}).then(res => {
      console.log(res.data)
      if (res.data.code == 0) {
        wx.showToast({
          title: '退回成功',
          icon: 'success'
        })
        this.data.bagList.forEach((item,index)=>{
          if(item.id == e.currentTarget.id){
            this.data.bagList.splice(index,1);
            let tempList = this.data.bagList;
            let tempMoney = 0;
            let tempIn = 0;
            for (let i = 0; i < tempList.length; i++) {
              if(tempList[i].checkStatus == 7){
                tempMoney = tempMoney + Number(tempList[i].inputAmount);
                tempIn = tempIn + Number(tempList[i].entryAmount);
              }
            }
            this.setData({
              bagList:this.data.bagList,
              sumMoney: tempMoney.toFixed(2),
              sumIn: tempIn.toFixed(2)
            })
          }
        })
      } else {
        console.log(res.data.message)
      }
    })
    
  },
  logout() {
    request('/smsk/wechat/auth/logout', 'POST').then(res => {
      console.log(res.data)
      if (res.data.code == 0) {
        wx.setStorageSync('userInfo', res.data.data)
        wx.setStorageSync('token', res.data.data.token)
        wx.redirectTo({
          url: '/pages/cashService/roleSelection/roleSelection',
        })
      } else {
        this.showToast(res.data.message)
      }
    })
  },
  /**
   * 工作台选择公司
   * @param {*} e 
   */
  companyPick(e){
    console.log(e)
    this.setData({
      bagList:[],
      ['queryOrder.cIndex']:e.detail.value,
      ['queryOrder.companyId']:this.data.comArray[e.detail.value].id,
      ['queryOrder.pageNo']:1,
      listHttpFlag: true,
      isEnd: false
    })
    this.fetchBagList();
    this.getStations(this.data.comArray[e.detail.value].id,'order');
  },
  /**
   * 工作台选择站点
   * @param {*} e 
   */
  stationPick(e){
    this.setData({
      bagList:[],
      ['queryOrder.sIndex']:e.detail.value,
      ['queryOrder.stationId']:this.data.stationArray[e.detail.value].id,
      ['queryOrder.pageNo']:1,
      listHttpFlag: true,
      isEnd: false
    })
    this.fetchBagList();
  },
  /**
   * 历史列表选择公司
   * @param {*} e 
   */
  companyPick_2(e){
    this.setData({
      doneList:[],
      ['queryDone.cIndex']:e.detail.value,
      ['queryDone.companyId']:this.data.comArray[e.detail.value].id,
      ['queryDone.pageNo']:1,
      listHttpFlag: true,
      isEnd: false
    })
    this.fetchDoneList();
    this.getStations(this.data.comArray[e.detail.value].id,'done');
  },
  /**
   * 展示金额填写框
   */
  selectMoney(e) {
    if (e.currentTarget.dataset.mode === 'queryOrder') {
      this.setData({
        showMoneySelector1: true,
        selectMode1: e.currentTarget.dataset.mode
      })
    } else {
      this.setData({
        showMoneySelector: true,
        selectMode: e.currentTarget.dataset.mode
      })
    }
  },
  /**
   * 关闭金额填写框
   */
  onCloseMoney(e) {
    if (e.currentTarget.dataset.mode === 'queryOrder') {
      this.setData({
        showMoneySelector1: false,
        selectMode1: ''
      })
    } else {
      this.setData({
        showMoneySelector: false,
        selectMode: ''
      })
    }
  },
  /**
   * 历史列表选择站点
   * @param {*} e 
   */
  stationPick_2(e){
    this.setData({
      doneList:[],
      ['queryDone.sIndex']:e.detail.value,
      ['queryDone.stationId']:this.data.stationArray2[e.detail.value].id,
      ['queryDone.pageNo']:1,
      listHttpFlag: true,
      isEnd: false
    })
    this.fetchDoneList();
  },
  /**
   * 切换底部tab
   */
  tabChange(e, str) {
    if (str == 'fresh') {
      // 手动刷新，获取tab组件，修改tab选中态
      this.selectComponent("#tabBar").switchTab(e, 'manual');
    } else {
      
      if (e.detail.id == '1') {
        // 弹出扫码方式选择
        this.setData({
          showIdInput:true
        })
      } else if (e.detail.id == '0') {
        this.setData({
          tabActive: e.detail.id,
          ['queryOrder.pageNo']: 1,
          bagList: [],
          isEnd:false,
          listHttpFlag:true
        })
        wx.setNavigationBarTitle({
          title: '清点工作台',
        })
        this.fetchBagList();
      } else if (e.detail.id == '2') {
        this.setData({
          tabActive: e.detail.id
        })
        wx.setNavigationBarTitle({
          title: '清点历史',
        })
        this.setData({
          ['queryDone.pageNo']: 1,
          doneList: [],
          isEnd:false,
          listHttpFlag:true
        })
        this.fetchDoneList() //获取已清点列表
      }
    }
  },
  /**
   * 获取已清点列表
   */
  fetchDoneList(){
    if(this.data.listHttpFlag === false){
      return;
    }
    this.data.listHttpFlag = false;
    request('/smsk/outsource/list', 'GET', this.data.queryDone).then(res => {
      this.data.listHttpFlag = true;
      // console.log(res.data)
      if (res.data.code == 0) {
        let tempList = this.data.doneList
        res.data.data.forEach(item => {
          tempList.push(item)
        })
        console.log('qqqq',this.data.queryDone.pageNo * this.data.queryDone.pageSize,res.data.total)
        if((this.data.queryDone.pageNo * this.data.queryDone.pageSize) >= res.data.total){
          this.setData({
            listHttpFlag: false
          })
          if(tempList.length > 0){
            this.setData({
              isEnd: true
            })
          }
        }
        if (tempList.length > 0) {
          this.setData({
            doneList: tempList
          })
        }
      } else {
        console.log(res)
      }
    })
  },
  /**
   * 执行扫码
   */
  doScan(){
    wx.scanCode({
      success(res) {
        console.log(res)
        wx.showToast({
          title: '查询中',
          icon: 'loading'
        })
        var tempQrcode = res.result
        request('/smsk/outsource/scan', 'GET', { code: tempQrcode }).then(res => {
          // console.log(res.data)
          if (res.data.code == 0) {
            if (res.data.data == null) {
              wx.navigateTo({
                url: '/pages/cashService/third/doCount/doCount',
              })
            } else {
              // 根据bagStatus判断箱包是否生成了订单
              if (res.data.data.bagsStatus === '7' || res.data.data.bagsStatus === '8' || res.data.data.bagsStatus === '9') {
                // 跳转箱包编辑页
                let bagInfo = JSON.stringify(res.data.data)
                wx.navigateTo({
                  url: '/pages/cashService/third/doCount/doCount?bagInfo=' + bagInfo,
                })
              } else if (res.data.data.bagsStatus === 'D') {
                // TODO 箱包删除，临时码不可再用/永久码可以再用
                wx.showToast({
                  title: '该箱包ID已使用',
                  icon: 'none'
                })
              }else {
                // 跳转详情页
                wx.navigateTo({
                  url: '/pages/cashService/third/detail/detail?orderId=' + res.data.data.orderId,
                })
              }
            }
          } else {
            wx.showToast({
              title: res.data.message,
              icon: 'none'
            })
          }
        })
      },
      fail(res) {
        wx.showToast({
          title: '扫码失败',
          icon: 'error'
        })
      }
    })
  },
    /**
   * 获取清点箱包列表
   */
  fetchBagList() {
    if(this.data.listHttpFlag === false){
      return;
    }
    this.data.listHttpFlag = false;
    var url = '/smsk/outsource/list';
    request(url, 'GET', this.data.queryOrder).then(res => {
      this.data.listHttpFlag = true;
      console.log(res.data)
      if (res.data.code == 0) {
        this.setData({
          totalMoney: res.data.detail.split(",")[0],
          listLength: res.data.total,
          totalIn: res.data.detail.split(",")[1]
        })
        let tempMoney = 0;
        let tempIn = 0;
        let tempList = this.data.bagList
        res.data.data.forEach(item => {
          item.inputAmount = item.inputAmount.toFixed(2);
          item.realCashAmount = item.realCashAmount.toFixed(2);
          tempList.push(item)
        })
        for (let i = 0; i < tempList.length; i++) {
          // console.log(Number(tempList[i].inputAmount))
          if(tempList[i].checkStatus == 7){
            tempMoney = tempMoney + Number(tempList[i].inputAmount);
            tempIn = tempIn + Number(tempList[i].entryAmount);
          }
        }
        console.log('qqqq',this.data.queryOrder.pageNo * this.data.queryOrder.pageSize,res.data.total)
        if((this.data.queryOrder.pageNo * this.data.queryOrder.pageSize) >= res.data.total){
          this.setData({
            listHttpFlag: false
          })
          if(tempList.length > 0){
            this.setData({
              isEnd: true
            })
          }
        }
        if (tempList.length > 0) {
          console.log(tempMoney)
          this.setData({
            bagList: tempList,
            sumMoney: tempMoney.toFixed(2),
            sumIn: tempIn.toFixed(2)
          })
        }
      } else {
        console.log(res)
      }
    })
  },
  bagIdInput(e){
    this.setData({
      bagCode:e.detail.value
    })
    console.log(e.detail.value)
  },
  /**
   * 获取订单详情并跳转清点
   */
  toCountDetail(){
    request('/smsk/outsource/scan', 'GET', { code: this.data.bagCode }).then(res => {
      // console.log(res.data)
      if (res.data.code == 0) {
        if (res.data.data == null) {
          wx.navigateTo({
            url: '/pages/cashService/third/doCount/doCount',
          })
        } else {
          // 根据bagStatus判断箱包是否生成了订单
          if (res.data.data.bagsStatus === '7' || res.data.data.bagsStatus === '8' || res.data.data.bagsStatus === '9') {
            // 跳转箱包编辑页
            let bagInfo = JSON.stringify(res.data.data)
            wx.navigateTo({
              url: '/pages/cashService/third/doCount/doCount?bagInfo=' + bagInfo,
            })
          } else if (res.data.data.bagsStatus === 'D') {
            // TODO 箱包删除，临时码不可再用/永久码可以再用
            wx.showToast({
              title: '该箱包ID已使用',
              icon: 'none'
            })
          }else {
            // 跳转详情页
            wx.navigateTo({
              url: '/pages/cashService/third/detail/detail?orderId=' + res.data.data.orderId,
            })
          }
        }
      } else {
        wx.showToast({
          title: res.data.message,
          icon: 'none'
        })
      }
    })
  },
  /**
   * 删除箱包
   */
  handleDelete(e) {
    // console.log(e.currentTarget)
    var id = e.currentTarget.id;
    // wx.showToast({
    //   title: '处理中',
    //   icon: 'loading'
    // })
    Dialog.confirm({
      message: '是否要删除该箱包？',
      confirmButtonText: '是',
      cancelButtonText: '否'
    }).then(() => {
      request('/smsk/outsource/counting/delete', 'POST', { id:id }).then(res => {
        console.log(res.data)
        if (res.data.code == 0) {
          wx.showToast({
            title: '删除成功',
            icon: 'success'
          })
          this.data.bagList.forEach((item,index)=>{
            if(item.id == id){
              this.data.bagList.splice(index,1);
              let tempList = this.data.bagList;
              let tempMoney = 0;
              let tempIn = 0;
              for (let i = 0; i < tempList.length; i++) {
                if(tempList[i].checkStatus == 7){
                  tempMoney = tempMoney + Number(tempList[i].inputAmount);
                  tempIn = tempIn + Number(tempList[i].entryAmount);
                }
              }
              this.setData({
                bagList:this.data.bagList,
                sumMoney: tempMoney.toFixed(2),
                sumIn: tempIn.toFixed(2)
              })
            }
          })
        } else {
          wx.showToast({
            title: res.data.message,
            icon: 'none'
          })
        }
      })
    }).catch(() => {
      // on cancel
    })
  },
  /**
   * 编辑箱包
   */
  handleEdit(e) {
    // console.log(e.currentTarget.dataset.item);
    let bagInfo = JSON.stringify(e.currentTarget.dataset.item)
    wx.navigateTo({
      url: '/pages/cashService/third/doCount/doCount?bagInfo=' + bagInfo,
    })
  },
  // 点击“发送银行”，展示提示窗
  showSubmitInfo() {
    if (this.data.bagList.length == 0) {
      return
    }
    this.setData({ showSubmitInfo: true })
    return
  },
  // 关闭发送提示窗
  onSubmitInfoClose() {
    this.setData({ showSubmitInfo: false })
  },
  /**
   * 展开
   * @param {*} event 
   */
  collapseChange(event) {
    this.setData({
      activeNames: event.detail,
    });
  },
  /**
   * 历史列表展开
   * @param {*} event 
   */
  collapseChange_2(event) {
    this.setData({
      activeNames2: event.detail,
    });
  },
  /**
   * 展示日期选择器
   */
  selectTime(e) {
    if (e.currentTarget.dataset.mode === 'queryOrder') {
      this.setData({
        showTimeSelector1: true,
        selectMode1: e.currentTarget.dataset.mode
      })
    } else {
      this.setData({
        showTimeSelector: true,
        selectMode: e.currentTarget.dataset.mode
      })
    }
  },
  /**
   * 关闭日期选择器
   */
  onCloseTime(e) {
    if (e.currentTarget.dataset.mode === 'queryOrder') {
      this.setData({
        showTimeSelector1: false,
        selectMode1: ''
      })
    } else {
      this.setData({
        showTimeSelector: false,
        selectMode: ''
      })
    }
  },
  /**
   * 设置选择的日期
   */
  onConfirmTime(event) {
    const [start, end] = event.detail;
    this.setData({
      showTimeSelector: false,
      [this.data.selectMode + '.date']: `${this.formatDateMD(start)} - ${this.formatDateMD(end)}`,
      [this.data.selectMode + '.payDateStart']: `${this.formatDateYMD(start)}`,
      [this.data.selectMode + '.payDateEnd']: `${this.formatDateYMD(end)}`,
    });
    console.log(this.data[this.data.selectMode].date)
    if (this.data.selectMode === 'queryOrder') {
      this.setData({ ['queryOrder.pageNo']: 1, listHttpFlag: true, isEnd: false, bagList: []})
      this.fetchBagList()
    } else {
      this.setData({ ['queryDone.pageNo']: 1, listHttpFlag: true, isEnd: false, doneList: []})
      this.fetchDoneList()
    }
  },
  /**
   * 清点工作台界面设置选择的日期
   */
  onConfirmTime1(event) {
    const [start, end] = event.detail;
    this.setData({
      showTimeSelector1: false,
      [this.data.selectMode1 + '.date']: `${this.formatDateMD(start)} - ${this.formatDateMD(end)}`,
      [this.data.selectMode1 + '.payDateStart']: `${this.formatDateYMD(start)}`,
      [this.data.selectMode1 + '.payDateEnd']: `${this.formatDateYMD(end)}`,
    });
    console.log(this.data[this.data.selectMode1].date)
    if (this.data.selectMode1 === 'queryOrder') {
      this.setData({ ['queryOrder.pageNo']: 1, listHttpFlag: true, isEnd: false, bagList: []})
      this.fetchBagList()
    } else {
      this.setData({ ['queryDone.pageNo']: 1, listHttpFlag: true, isEnd: false, doneList: []})
      this.fetchDoneList()
    }
  },
  formatDateMD(date) {
    date = new Date(date);
    return `${date.getMonth() + 1}/${date.getDate()}`;
  },
  formatDateYMD(date) {
    date = new Date(date);
    var y = date.getFullYear()+'';
    var m = (date.getMonth() + 1) < 10? '0'+ (date.getMonth() + 1) : (date.getMonth() + 1)+'';
    var d = date.getDate() < 10? '0'+ date.getDate() : date.getDate()+'';
    return y+m+d;
  },
  /**
   * 清空日期筛选
   */
  cleanDate(e) {
    this.setData({
      [e.currentTarget.dataset.mode + '.date']: '',
      [e.currentTarget.dataset.mode + '.payDateStart']: '',
      [e.currentTarget.dataset.mode + '.payDateEnd']: '',
    })
    if (e.currentTarget.dataset.mode === 'queryOrder') {
      this.setData({ ['queryOrder.pageNo']: 1, listHttpFlag: true, isEnd: false, bagList: [] })
      this.fetchBagList()
    } else {
      this.setData({ ['queryDone.pageNo']: 1, listHttpFlag: true, isEnd: false, doneList: []})
      this.fetchDoneList()
    }
  },
  toBagDetail(e){
    let id = e.currentTarget.id;
    wx.navigateTo({
      url: '/pages/cashService/third/detail/detail?orderId='+id,
    })
  },
  toUnCheckPage(){
    wx.navigateTo({
      url: '/pages/cashService/third/unCheckList/unCheckList',
    })
  },
  /**
   * 清空填写金额
   */
  cleanMoney(e) {
    if (e.currentTarget.dataset.mode === 'queryOrder') {
      this.setData({
        minMoney: '',
        maxMoney: '',
        ['queryOrder.minMoney']: '',
        ['queryOrder.maxMoney']: '',
      })
      this.setData({ ['queryOrder.pageNo']: 1, bagList: [] , isEnd: false, listHttpFlag: true})
      this.fetchBagList()
    } else {
      this.setData({
        minMoney: '',
        maxMoney: '',
        ['queryDone.minMoney']: '',
        ['queryDone.maxMoney']: '',
      })
      this.setData({ ['queryDone.pageNo']: 1, doneList: [] , isEnd: false, listHttpFlag: true})
      this.fetchDoneList()
    }
  },
  /**
   * 确认填写金额
   */
  onConfirmMoney(e) {
    if (e.currentTarget.dataset.mode === 'queryOrder') {
      this.setData({
        ['queryOrder.minMoney']:this.data.minMoney,
        ['queryOrder.maxMoney']:this.data.maxMoney,
        showMoneySelector1: false,
        selectMode1: ''
      })
      this.setData({ ['queryOrder.pageNo']: 1, bagList: [] , isEnd: false, listHttpFlag: true})
      this.fetchBagList()
    } else {
      this.setData({
        ['queryDone.minMoney']:this.data.minMoney,
        ['queryDone.maxMoney']:this.data.maxMoney,
        showMoneySelector: false,
        selectMode: ''
      })
      this.setData({ ['queryDone.pageNo']: 1, doneList: [] , isEnd: false, listHttpFlag: true})
      this.fetchDoneList()
    }
  },
  lineChange(e){
    const mode = e.currentTarget.dataset.mode;
    console.log(mode,e);
    if(mode === 'queryDone'){
      this.setData({
        ['queryDone.lineId']:this.data.lineArr[e.detail.value].lineId,
        ['queryDone.lineIndex']:e.detail.value,
        listHttpFlag:true
      })
      this.fetchDoneList()
    }else if(mode === 'queryOrder'){
      this.setData({
        ['queryOrder.lineId']:this.data.lineArr[e.detail.value].lineId,
        ['queryOrder.lineIndex']:e.detail.value,
        listHttpFlag:true
      })
      this.fetchBagList()
    }
  }
})